import Vue from 'vue'
import Vuex from 'vuex'
import $ from 'jquery'
/**
 * @desc 导入需要的store
 * @author wtniu
 */
import MenuStore from './MenuStore'
import IndexStore from './IndexStore'
import ListStore from './ListStore'
import DetailStore from './DetailStore'
import StaticStore from './StaticStore'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		historyLength: 0
	},
	getters: {
		count: state => {
			return state.historyLength
		}
	},
	mutations: {
		/*
		 * @desc 记录路由切换次数
		 * @arg {object} state 状态
		 */
		updateHistoryLength(state) {
			state.historyLength++
		},
		setCurrentItem(state, elem) {
			elem.css("color", "red")
		}
	},
	actions: {
		updateHistoryLength({
			commit
		}) {
			commit('updateHistoryLength')
		}
	},
	modules: {
		MenuStore,
		IndexStore,
		ListStore,
		DetailStore,
		StaticStore
	}
})